<template>
	<view class="">
		<view class="conyerList">
			<textarea v-model="content.text" class="textarea" maxlength="-1" placeholder="请输入内容" />
		</view>
		<view class="sss1111">
			<vastwu-saveimg :imgListprop="photo_list" :num='9' :isBase64='true' :isSave='true' :size='180' @chooseImage='imglist_msg'  @delImg='del_imglist_msg'></vastwu-saveimg>
		</view>
		<view class="conterListArr" @click="sendMsg">
			发布
		</view>
	</view>
</template>

<script>
	 import vastwuSaveimg from '../../components/vastwu-saveimg/vastwu-saveimg.vue'
	import {
		Request
	} from '@/utils/request.js';
	export default{
		data(){
			return{
				photo_list:[],
				content:{"text":"","value":[""]},
			}
		},
		components:{
			vastwuSaveimg
		},
		methods:{
			del_imglist_msg(){
				
			},
			imglist_msg(tempFilePaths){
				// /im/upload/circle
				console.log(tempFilePaths.tempFilePath)
				for(var i =0;i<tempFilePaths.tempFilePath.length;i++){
					console.log(tempFilePaths.tempFilePath[i])
					 uni.uploadFile({
								url: 'https://im.xwjgene.com/im/upload/circle', //仅为示例，非真实的接口地址
								filePath: tempFilePaths.tempFilePath[i],
								name: 'file',
								header:{
									'Authori-zation':'Bearer '+uni.getStorageSync('token'),
									'Form-type':null
								},
								formData: {
									'user': 'test',
									len:1,
								},
								success: (uploadFileRes) => {
									 let {data} =JSON.parse(uploadFileRes.data);
									this.content.value[i]=data.save_name
									// console.log();
								}
							});
					// uni.uploadFile({
					// 	url: 'https://im.xwjgene.com/im/upload/circle', //仅为示例，非真实的接口地址
					// 	filePath:tempFilePaths.tempFilePath[i],
					// 	name: 'file',
					// 	header:{
					// 		'Authori-zation':'Bearer '+uni.getStorageSync('token'),
					// 		'Form-type':null
					// 	},
					// 	success: (uploadFileRes) => {
					// 		// let {data} =JSON.parse(uploadFileRes.data);
					// 		// this.userInfoJson.avatar=data.url;
					// 		// this.formData.avatar=data.url;
					// 		// this.isConte=false;
					// 	}
					// });
				}
				
			},
			sendMsg(){
				Request('im/circle/sendMsg',{
					content:JSON.stringify(this.content),
				},'post').then((res)=>{
					uni.navigateBack({ delta: 1 })
				})
			}
			// /im/circle/sendMsg
		}
	}
</script>

<style>
	.conyerList{
		width: 702rpx;
		height: 480rpx;
		margin: 0 auto;
		margin-top: 24rpx;
		background: #F7F8FA;
		box-sizing: border-box;
		padding: 20rpx;
		border-radius: 16rpx 16rpx 16rpx 16rpx;
	}
	.conyerList .textarea{
		width: 100%;
		height: 100%;
	}
	.conterListArr{
		width: 702rpx;
		height: 88rpx;
		margin: 0 auto;
		background: #256FF3;
		border-radius: 16rpx 16rpx 16rpx 16rpx;
		font-family: PingFang SC, PingFang SC;
		font-weight: 500;
		font-size: 28rpx;
		color: #FFFFFF;
		line-height: 88rpx;
		position: fixed;
		left: 50%;
		transform: translate(-50%);
		bottom: 100rpx;
		text-align: center;
		font-style: normal;
		text-transform: none;
	}
</style>